<template>
  <el-container class="home_main">
    <el-header>
      <div class="header-lf">
        <div class="logo flx-center">
          <img class="logo-img" src="@/assets/logo.png" alt="logo" />
          <span class="logo-text">micro-app</span>
        </div>
      </div>
      <div class="header-ri"></div>
    </el-header>
    <el-container class="classic-content">
      <div class="sys_list">
        <section v-for="(item, i) in menuList" :key="i" class="sys_wrap">
          <div :class="['sys_title', { sys: item.path == '/pms' }]">
            <el-icon class="icon">
              <component :is="item.meta.icon" />
            </el-icon>
            <div class="title">{{ item.meta.title }}</div>
          </div>
          <div class="module_wrap">
            <div v-for="(cItem, cI) in item.children" :key="`${i}-${cI}`" class="module" @click="routeHandle(cItem)">
              <el-icon class="font_family">
                <component :is="cItem.meta.icon" />
              </el-icon>
              <div class="module_name">{{ cItem.meta.title }}</div>
            </div>
          </div>
        </section>
      </div>
    </el-container>
  </el-container>
</template>
<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
const menuList = reactive([
  {
    path: '/dashboard',
    meta: {
      title: '仪表盘',
      icon: 'HomeFilled'
    },
    children: [
      {
        path: '/vue2App',
        name: 'vue2App',
        type: 'microapp',
        meta: {
          title: 'micro-app-vue2',
          icon: 'Van'
        }
      },
      {
        path: '/vue2AdminApp',
        name: 'vue2AdminApp',
        type: 'microapp',
        meta: {
          title: 'micro-app-vue2-admin',
          icon: 'Tools'
        }
      }
    ]
  },
  {
    path: '/pms',
    meta: {
      title: '产品管理',
      icon: 'HelpFilled'
    },
    children: [
      {
        path: '/vue3AdminApp',
        name: 'vue3AdminApp',
        type: 'microapp',
        meta: {
          title: 'micro-app-vue3-admin',
          icon: 'Platform'
        }
      },
      {
        path: '/vite3App',
        name: 'vite3App',
        meta: {
          title: 'micro-app-viteVue3',
          icon: 'DataLine'
        }
      },
      {
        path: '/wujieVite3App',
        name: 'wujieVite3App',
        type: 'wujie',
        meta: {
          title: 'wujie-viteVue3',
          icon: 'ScaleToOriginal'
        }
      }
    ]
  }
])
const routeHandle = item => {
  if (item.name === 'vite3App') {
    router.push('/')
  } else {
    router.push({ path: '/sub-app', query: { path: item.path, name: item.name, type: item.type } })
  }
}
</script>

<style scoped lang="scss">
.home_main {
  width: 100%;
  height: 100%;
}
.el-container {
  width: 100%;
  height: 100%;
  :deep(.el-header) {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 55px;
    padding: 0 15px 0 0;
    background-color: #191a20;
    border-bottom: 1px solid #191a20;
    .header-lf {
      display: flex;
      align-items: center;
      overflow: hidden;
      white-space: nowrap;
      .logo {
        flex-shrink: 0;
        width: 260px;
        margin-right: 16px;
        cursor: pointer;
        .logo-img {
          width: 40px;
          height: 40px;
          margin-right: 6px;
          border-radius: 50%;
        }
        .logo-text {
          font-size: 21.5px;
          font-weight: bold;
          color: #dadada;
          white-space: nowrap;
          vertical-align: middle;
        }
      }
    }
    .header-ri {
      .tool-bar-ri {
        .toolBar-icon,
        .username {
          color: #e5eaf3;
        }
      }
    }
  }
  .classic-content {
    display: flex;
    height: calc(100% - 50px);
    position: relative;
    padding: 4px;
    .sys_list {
      margin-top: 20px;
      .sys_wrap {
        position: relative;
        background: var(--el-bg-color);
        border-radius: 8px;
        display: flex;
        align-items: center;
        margin-bottom: 15px;

        .sys_title {
          position: absolute;
          left: 0;
          right: 0;
          top: 0;
          bottom: 0;
          display: flex;
          justify-content: center;
          align-items: center;
          flex-direction: column;
          width: 250px;
          border-radius: 8px;
          background-image: url('../../assets/nav_system-bg.png'),
            linear-gradient(138.83deg, #b5d7ff 5.54%, rgba(162, 197, 238, 0.38) 98.12%);

          .icon {
            font-size: 60px;
          }

          .title {
            font-weight: 500;
            font-size: 30px;
            line-height: 42px;
            color: #04081c;
          }
        }

        .sys {
          background-image: url('../../assets/nav_system-bg.png'),
            linear-gradient(138.83deg, #ffcbb5 5.54%, rgba(238, 180, 162, 0.38) 98.12%);
        }

        .module_wrap {
          display: flex;
          flex-wrap: wrap;
          padding-left: 280px;

          .module {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 194px;
            height: 154px;
            font-size: 16px;
            border-radius: 4px;
            margin: 15px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;

            &:hover {
              background: var(--el-bg-color);
              box-shadow: 0px 8px 15px #928b94;
              border-radius: 26px;
            }

            .module_name {
              margin-top: 10px;
              color: var(--el-text-color-primary);
            }

            .font_family {
              font-size: 78px;
              color: #355db4;
              line-height: 1;
            }
          }
        }
      }
    }
    .classic-main {
      display: flex;
      flex-direction: column;
    }
  }
}
</style>
